package indi.kider.server.qiniu.api;

import indi.kider.server.qiniu.service.QiniuUpTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.vankid.common.model.base.CommonResponse;

@RestController
@RequestMapping(produces = "application/json;charset=UTF-8")
public class QiniuController {

    @Autowired
    QiniuUpTokenService qiniuUpTokenService;

    @GetMapping(value = "/token")
    public CommonResponse getUpToken() {
        return CommonResponse.buildGetSuccessResponse(qiniuUpTokenService.getUpToken());
    }

    @PutMapping(value = "/token")
    public CommonResponse updateUpToken() {
        qiniuUpTokenService.updateToken();
        return CommonResponse.buildGetSuccessResponse("");
    }
}
